﻿namespace TfsCloudDeploy.Workflow.Core
{
    using System;
    using System.ComponentModel;

    /// <summary>
    /// Stores metadata about the database server instance and the associated deployment database(s).
    /// </summary>
    [Serializable, TypeConverter(typeof(DatabaseServerInstanceConverter))]
    public class DatabaseServerInstance
    {
        public DatabaseServerInstance()
        {
        }

        public DatabaseServerInstance(string serverInstanceName, string databaseName)
        {
            this.ServerInstanceName = serverInstanceName;
            this.DatabaseName = databaseName;
        }

        [Browsable(true)]
        public virtual string ServerInstanceName { get; set; }

        [Browsable(true)]
        public virtual string DatabaseName { get; set; }

        [Browsable(true)]
        public virtual bool IsDeployable { get; set; }

        /// <summary>
        /// When specified, overrides the global connection string setting.
        /// </summary>
        [Browsable(true)]
        public string TargetDatabaseConnectionString { get; set; }

        /// <summary>
        /// When specified, overrides the global deployment properties.
        /// </summary>
        [Browsable(true)]
        public string AdditionalDeploymentParameters { get; set; }

        public override string ToString()
        {
            return string.Format("Server: {0} - Database: {1} - Deploy={2}",
                this.ServerInstanceName,
                this.DatabaseName,
                this.IsDeployable ? "Yes" : "No");
        }
    }
}
